﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aludra.Core.Models;

namespace Aludra.Desktop.Core
{
    public enum CardGamePlayerStatus
    {
        Unspecified,
        Won,
        Lost
    }

    public class CardGamePlayer
    {
        public int LifePoint { get; set; }
		
        public CardGamePlayerStatus Status
        {
            get;
            set;
        }
				
        public event EventHandler<CardsRemovedEventArgs> CardsRemoved;

        public event EventHandler<CardsAddedEventArgs> CardsAdded;

        public BanishedZone MyBanishedZone { get; set; }
        public DeckZone MyDeckZone { get; set; }
        public ExtraDeckZone MyExtraDeckZone { get; set; }
        public FieldCardZone MyFieldCardZone { get; set; }
        public GraveZone MyGraveZone { get; set; }
        public HandZone MyHandZone { get; set; }
        public MonsterZone MyMonsterZone { get; set; }
        public SpellTrapZone MySpellTrapZone { get; set; }

        public CardGamePlayer(DeckZone deckZone, ExtraDeckZone extraDeckZone)
        {
            this.MyDeckZone = deckZone;
			this.MyDeckZone.CardsAdded += HandleCardsAdded;
			this.MyDeckZone.CardsRemoved += HandleCardsRemoved;
			
			this.MyExtraDeckZone = extraDeckZone;
			
			this.MyBanishedZone = new BanishedZone();
			this.MyBanishedZone.CardsAdded += HandleCardsAdded;
			this.MyBanishedZone.CardsRemoved += HandleCardsRemoved;
			
			this.MyFieldCardZone = new FieldCardZone();
			this.MyFieldCardZone.CardsAdded += HandleCardsAdded;
			this.MyFieldCardZone.CardsRemoved += HandleCardsRemoved;
			
			this.MyGraveZone = new GraveZone();
			this.MyGraveZone.CardsAdded += HandleCardsAdded;
			this.MyGraveZone.CardsRemoved += HandleCardsRemoved;
			
			this.MyHandZone = new HandZone(new List<ICard>());
			this.MyHandZone.CardsAdded += HandleCardsAdded;
			this.MyHandZone.CardsRemoved += HandleCardsRemoved;
			
			this.MyMonsterZone = new MonsterZone();
			this.MyMonsterZone.CardsAdded += HandleCardsAdded;
			this.MyMonsterZone.CardsRemoved += HandleCardsRemoved;
			
			this.MySpellTrapZone = new SpellTrapZone();	
			this.MySpellTrapZone.CardsAdded += HandleCardsAdded;
			this.MySpellTrapZone.CardsRemoved += HandleCardsRemoved;		
        }

        private void HandleCardsRemoved (object sender, CardsRemovedEventArgs e)
        {
			if(this.CardsRemoved != null)
			{
				this.CardsRemoved(this, e);
			}        	
        }

        private void HandleCardsAdded (object sender, CardsAddedEventArgs e)
        {
			if(this.CardsAdded != null)
			{
				this.CardsAdded(this, e);
			}
        }
    }
}
